//package com.zmn.plat.task.listenter;
//
//import com.alibaba.fastjson.JSONObject;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.plat.manager.utils.MqConsts;
//import com.zmn.plat.model.entity.log.SysLog;
//import com.zmn.plat.services.interfaces.log.SysLogService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.core.MessageListener;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
///**
// * 系统日志写入请求监听器
// * 如mq中不存在指定的queues会导致应用退出
// * @author nowind
// * @since 2017/9/20 15:20
// */
//@Component
//@RabbitListener(queues = MqConsts.MQ_SYSLOG_QUEUE)
//public class SysLogQueueListenter {
//    private Logger logger = LoggerFactory.getLogger(SysLogQueueListenter.class);
//
//    @Autowired
//    private SysLogService sysLogService;
//
//
//    @RabbitHandler
//    public void process(String message) {
//
//        try {
//
//            if(StringUtil.isBlank(message)) {
//                logger.error(String.format("[zmn]系统日志消息为空,message:[%s]", message));
//                return;
//            }
//
//            // 解析消息内容
//            SysLog log = JSONObject.parseObject(message, SysLog.class);
//
//            sysLogService.add(log);
//
//        } catch(Exception ex){
//
//            logger.error(String.format("[zmn]监听系统日志消息并写入数据库出错,message:[%s],ex:[%s]", message, ex.getMessage()));
//        }
//    }
//}
